package nl.unimaas.micc.umsnooker.domain;

import nl.unimaas.micc.umsnooker.simulation.event.Event;
import nl.unimaas.micc.umsnooker.simulation.event.PocketingEvent;
import nl.unimaas.micc.umsnooker.simulation.physics.Physics;

import com.jme.math.Vector3f;

public class Pocket extends SphericalGameObject
{	
	private float outerRadius;
	
	public Pocket(Vector3f position, float outerRadius)
	{
		setPosition(position);
		setRadius(outerRadius);	
		setOuterRadius(outerRadius);
	}
	
	public void setOuterRadius(float outerRadius)
	{
		this.outerRadius = outerRadius;
	}
	
	public float getOuterRadius()
	{
		return outerRadius;
	}

	@Override
	public Event findCollision(BilliardBall b)
	{
		setRadius(outerRadius-b.getRadius());
		double time = Physics.collisionTime(b, this);
		
		if(time>=0)
		{
			return new PocketingEvent((float) (b.getTime() + time), b,this);
		}
		else
		{
			return null;
		}
	}
}
